package com.yiwei.app.modules.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yiwei.app.common.utils.Constants;
import com.yiwei.app.common.utils.ResultEntity;
import com.yiwei.app.modules.entity.BillInfo;
import com.yiwei.app.modules.entity.ContractInfo;
import com.yiwei.app.modules.entity.CustomerInfo;
import com.yiwei.app.modules.entity.OrderInfo;
import com.yiwei.app.modules.service.InformationService;

/**********
 * 订单信息 、合同信息、大客户信息 、账单信息
 * @author fanguangcong
 * 
 */
@Controller
@RequestMapping(value="/information/")
public class InformationController {
	

	 @Autowired
	 private InformationService informationService;
	  ResultEntity result=new ResultEntity();
	 @ResponseBody
	 @RequestMapping(value="saveOrderInfo",method=RequestMethod.POST)
	 public ResultEntity saveOrderInfo(OrderInfo orderInfo,String areaId){
		           
		       boolean flag = informationService.insertorderInfo(orderInfo);
		       
		       if(flag){
		    	   result.setCode(Constants.SUCCESS_CODE);
		    	   result.setMessage(Constants.SUCCESS_MESS);
		    	   return result;
		       }
		       result.setCode(Constants.ERROR_CODE);
		       result.setMessage(Constants.ERROR_MESS);
		 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectOrderById",method=RequestMethod.GET)
	  public OrderInfo selectOrderInfoById(String delFlag,String id){
		OrderInfo orderInfo = informationService.selectbyOrderInfoId(id);
	    return orderInfo;
	  }
	 @ResponseBody
	 @RequestMapping(value="updateOrderInfo",method=RequestMethod.POST)
	 public ResultEntity updateOrderInfo(OrderInfo orderInfo){
		           boolean flag = informationService.updateorderInfo(orderInfo);
		           if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="delete",method=RequestMethod.GET)
	 public ResultEntity deleteOrderInfo(String delFlag,String id){
		        boolean flag = informationService.deleteorderInfo(delFlag, id);
		        if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectOrderInfo",method=RequestMethod.GET)
	 public List selectOrderInfo(String pageNum,String pageSize){
		 List list = informationService.selectOrderInfoList(pageNum, pageSize);
		 return list;
	 }
	 /***********
	  * 大客户信息
	  */
	 @ResponseBody
	 @RequestMapping(value="saveCustomerInfo",method=RequestMethod.POST)
	 public ResultEntity saveCustomerInfo(CustomerInfo customerInfo,String areaId){
		           
		       boolean flag = informationService.insertCustomerInfo(customerInfo);
		       
		       if(flag){
		    	   result.setCode(Constants.SUCCESS_CODE);
		    	   result.setMessage(Constants.SUCCESS_MESS);
		    	   return result;
		       }
		       result.setCode(Constants.ERROR_CODE);
		       result.setMessage(Constants.ERROR_MESS);
		 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectCustomerInfoById",method=RequestMethod.GET)
	  public CustomerInfo selectCustomerInfoById(String id){
		CustomerInfo customerInfo = informationService.selectCustomerInfoById(id);
	    return customerInfo;
	  }
	 @ResponseBody
	 @RequestMapping(value="updateCustomerInfo",method=RequestMethod.POST)
	 public ResultEntity updateCustomerInfo(CustomerInfo customerInfo){
		           boolean flag = informationService.updateCustomerInfo(customerInfo);
		           if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="deleteCustomerInfo",method=RequestMethod.GET)
	 public ResultEntity deleteCustomerInfo(String delFlag,String id){
		        boolean flag = informationService.deleteCustomerInfobyId(delFlag, id);
		        if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectCustomerInfo",method=RequestMethod.GET)
	 public List selectCustomerInfo(String pageNum,String pageSize){
		 List list = informationService.selectCustomerInfoList(pageNum, pageSize);
		 return list;
	 }
	 /*********
	  * 合同信息
	  * @param contractInfo
	  * @param areaId
	  * @return
	  */
	 @ResponseBody
	 @RequestMapping(value="saveContractInfo",method=RequestMethod.POST)
	 public ResultEntity saveContractInfo(ContractInfo contractInfo,String areaId){
		           
		       boolean flag = informationService.insertContractInfo(contractInfo);
		       
		       if(flag){
		    	   result.setCode(Constants.SUCCESS_CODE);
		    	   result.setMessage(Constants.SUCCESS_MESS);
		    	   return result;
		       }
		       result.setCode(Constants.ERROR_CODE);
		       result.setMessage(Constants.ERROR_MESS);
		 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectContractInfoById",method=RequestMethod.GET)
	  public ContractInfo selectContractInfobyId(String id){
		ContractInfo contractInfo = informationService.selectContractInfoById(id);
	    return contractInfo;
	  }
	 @ResponseBody
	 @RequestMapping(value="updateContractInfo",method=RequestMethod.POST)
	 public ResultEntity updateContractInfo(ContractInfo contractInfo){
		           boolean flag = informationService.updateContractInfo(contractInfo);
		           if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="deleteContractInfo",method=RequestMethod.GET)
	 public ResultEntity deleteContractInfo(String delFlag,String id){
		        boolean flag = informationService.deleteContractInfobyId(delFlag, id);
		        if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectContractInfo",method=RequestMethod.GET)
	 public List selectContractInfo(String pageNum,String pageSize){
		 List list = informationService.selectContractInfoList(pageNum, pageSize);
		 return list;
	 }
	 
	 /*********
	  * 账单信息
	  * @param contractInfo
	  * @param areaId
	  * @return
	  */
	 @ResponseBody
	 @RequestMapping(value="saveBillInfo",method=RequestMethod.POST)
	 public ResultEntity saveBillInfo(BillInfo billInfo,String areaId){
		           
		       boolean flag = informationService.insertBillInfo(billInfo);
		       
		       if(flag){
		    	   result.setCode(Constants.SUCCESS_CODE);
		    	   result.setMessage(Constants.SUCCESS_MESS);
		    	   return result;
		       }
		       result.setCode(Constants.ERROR_CODE);
		       result.setMessage(Constants.ERROR_MESS);
		 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectBillInfoById",method=RequestMethod.GET)
	  public BillInfo selectBillInfobyId(String id){
		BillInfo billInfo = informationService.selectBillInfoById(id);
	    return billInfo;
	  }
	 @ResponseBody
	 @RequestMapping(value="updateBillInfo",method=RequestMethod.POST)
	 public ResultEntity updateBillInfo(BillInfo billInfo){
		           boolean flag = informationService.updateBillInfo(billInfo);
		           if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="deleteBillInfo",method=RequestMethod.GET)
	 public ResultEntity deleteBillInfo(String delFlag,String id){
		        boolean flag = informationService.deleteBillInfobyId(delFlag, id);
		        if(flag){
			    	   result.setCode(Constants.SUCCESS_CODE);
			    	   result.setMessage(Constants.SUCCESS_MESS);
			    	   return result;
			       }
			       result.setCode(Constants.ERROR_CODE);
			       result.setMessage(Constants.ERROR_MESS);
			 return result;
	 }
	 @ResponseBody
	 @RequestMapping(value="selectBillInfo",method=RequestMethod.GET)
	 public List<BillInfo> selectBillInfo(String pageNum,String pageSize){
		  List<BillInfo> list = informationService.selectBillInfoList(pageNum, pageSize);
		 return list;
	 }
}
